home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
C64
/
U-Utilities
/
(c)u1.d64
/
format.c
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2007-02-04
|
811b
|
38 lines
5 REM FORMAT
6 REM BY BOB HUFFMAN
10 FOR R=1 TO 25
20 B=INT(6*RND(1))
30 B=10^B
40 A=RND(1)*B
50 G=A:F=9.3:GOSUB 10000
60 A$=G$:PRINT A TAB(16) A$:NEXT:END
70 :
80 :
90 :
10000 G$="":W=INT(F):D=INT((F-W)*10+.5)
10010 IF D=0 THEN 10170
10020 IF G<10^(W-D-1) THEN 10050
10030 FORN=1TO (W-D-1):G$=G$+"*":NEXT:G$=G$+"."
10040 FORN=1 TO D:G$=G$+"*":NEXT:RETURN
10050 P=INT(10^D)
10055 G2=G:IF G<.01 THEN G2=G+1
10060 G$=STR$(INT(G2*P+.5)/P)
10070 G$=RIGHT$(G$,LEN(G$)-1)
10080 IFG<.01 THEN G$=RIGHT$(G$,LEN(G$)-1)
10090 FOR N=1 TO LEN(G$):IF MID$(G$,N,1)="."THEN 10130
10100 NEXT
10110 G$=G$+"."
10120 FOR N=1 TO D:G$=G$+"0":NEXT:GOTO 10150
10130 G$=LEFT$(G$,N+D)
10135 IF D=LEN(G$)-N THEN 10150
10140 FOR L=LEN(G$)-N+1 TO D:G$=G$+"0":NEXT
10150 IF LEFT$(G$,1)="." THEN G$="0"+G$
10155 IF LEN(G$)=W THEN RETURN
10160 FOR N=LEN(G$)+1 TO W:G$=" "+G$:NEXT:RETURN
10170 IF G<10^W THEN 10190
10180 FOR N=1 TO W:G$=G$+"*":NEXT:RETURN
10190 G$=STR$(INT(G+.5))
10200 G$=RIGHT$(G$,LEN(G$)-1)
10210 IF LEN(G$)=W THEN RETURN
10220 FOR N=LEN(G$)+1 TO W:G$=" "+G$:NEXT:RETURN